package com.voe.callback;

import com.voe.common.ModifiedValue;
import com.voe.common.OutputParam;

public abstract class AudioTransport {

	protected abstract int recordedDataIsAvailable(byte[] audioSamples,
			int nSamples, byte nBytesPerSample, byte nChannels,
			int samplesPerSec, int totalDelayMS, int clockDrift,
			int currentMicLevel, ModifiedValue<Integer> newMicLevel);

	protected abstract int needMorePlayData(int nSamples, byte nBytesPerSample,
			byte nChannels, int samplesPerSec, byte[] audioSamples,
			ModifiedValue<Integer> samplesOut);

	protected int recordedDataIsAvailable(byte[] audioSamples, int nSamples,
			byte nBytesPerSample, byte nChannels, int samplesPerSec,
			int totalDelayMS, int clockDrift, int currentMicLevel,
			OutputParam newMicLevel) {
		ModifiedValue<Integer> ret = new ModifiedValue<Integer>();
		int result = recordedDataIsAvailable(audioSamples, nSamples,
				nBytesPerSample, nChannels, samplesPerSec, totalDelayMS,
				clockDrift, currentMicLevel, ret);
		newMicLevel.setObject(new Object[] { ret.getValue() });
		return result;
	}

	protected int needMorePlayData(int nSamples, byte nBytesPerSample,
			byte nChannels, int samplesPerSec, byte[] audioSamples,
			OutputParam samplesOut) {
		ModifiedValue<Integer> ret = new ModifiedValue<Integer>();
		int result = needMorePlayData(nSamples, nBytesPerSample, nChannels,
				samplesPerSec, audioSamples, ret);
		samplesOut.setObject(new Object[] { ret.getValue() });
		return result;
	}
}
